<?php

namespace app\admin\model;

use think\Model;


class Orderdownload extends Model
{

    

    

    // 表名
    protected $name = 'order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_agency_text',
        'platform_type_text',
        'is_callback_text',
        'order_status_text',
        'is_recharged_text',
        'callback_time_text',
        'jiesuan_time_text',
        'settlement_time_text',
        'actime_text',
        'audit_time_text',
        'baoxiao_status_text',
        'recover_status_text',
        'recover_time_text',
        'audit_upload_time_text',
        'baoxiao_time_text'
    ];
    

    
    public function getIsAgencyList()
    {
        return ['1' => __('Is_agency 1'), '2' => __('Is_agency 2')];
    }

    public function getPlatformTypeList()
    {
        return ['1' => __('Platform_type 1'), '2' => __('Platform_type 2'), '3' => __('Platform_type 3')];
    }

    public function getIsCallbackList()
    {
        return ['1' => __('Is_callback 1'), '2' => __('Is_callback 2')];
    }

    public function getOrderStatusList()
    {
        return ['0' => __('Order_status 0'), '1' => __('Order_status 1'), '2' => __('Order_status 2'), '3' => __('Order_status 3'), '4' => __('Order_status 4'), '5' => __('Order_status 5'), '6' => __('Order_status 6')];
    }

    public function getIsRechargedList()
    {
        return ['0' => __('Is_recharged 0'), '1' => __('Is_recharged 1')];
    }

    public function getBaoxiaoStatusList()
    {
        return ['0' => __('Baoxiao_status 0'), '1' => __('Baoxiao_status 1'), '2' => __('Baoxiao_status 2')];
    }

    public function getRecoverStatusList()
    {
        return ['1' => __('Recover_status 1'), '2' => __('Recover_status 2')];
    }


    public function getIsAgencyTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_agency']) ? $data['is_agency'] : '');
        $list = $this->getIsAgencyList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getImageAttr($value, $data){
        if(isset($data['image']) && isset($data['is_agency'])){
            if($data['is_agency'] == 1){
                $value = cdnurl($data['image'],true);
            }else{
                $value = config('site.user_url').$data['image'];
            }
        }
        return $value;
    }
    public function getCallImageAttr($value, $data){
        if(!empty($data['call_image']) && isset($data['is_agency'])){
            if($data['is_agency'] == 2){
                $value = config('site.user_url').$data['call_image'];
            }
        }
        return $value;
    }
    public function getPlatformTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['platform_type']) ? $data['platform_type'] : '');
        $list = $this->getPlatformTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsCallbackTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_callback']) ? $data['is_callback'] : '');
        $list = $this->getIsCallbackList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getOrderStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['order_status']) ? $data['order_status'] : '');
        $list = $this->getOrderStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsRechargedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_recharged']) ? $data['is_recharged'] : '');
        $list = $this->getIsRechargedList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCallbackTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['callback_time']) ? $data['callback_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getJiesuanTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['jiesuan_time']) ? $data['jiesuan_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getSettlementTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['settlement_time']) ? $data['settlement_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getActimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['actime']) ? $data['actime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getAuditTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['audit_time']) ? $data['audit_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getBaoxiaoStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['baoxiao_status']) ? $data['baoxiao_status'] : '');
        $list = $this->getBaoxiaoStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRecoverStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['recover_status']) ? $data['recover_status'] : '');
        $list = $this->getRecoverStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRecoverTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['recover_time']) ? $data['recover_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getAuditUploadTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['audit_upload_time']) ? $data['audit_upload_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getBaoxiaoTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['baoxiao_time']) ? $data['baoxiao_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setCallbackTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setJiesuanTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setSettlementTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setActimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setAuditTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setRecoverTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setAuditUploadTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setBaoxiaoTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
